package zgc.demo.consumer.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 编码方式配置ribbon负载均衡策略为随机，默认是轮询
 */
@Configuration
public class RibbonRuleConfig {

    /**
     * 负载均衡策略可配置为随机，轮询等等，具体看IRule接口的是实现类
     * @return
     */
    @Bean
    public IRule iRule() {
        return new RandomRule();
    }
}
